package oktx.feign.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import oktx.participant.JtaParticipant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by dave on 18-5-28 下午9:04.
 */
public class FeignTxInterceptor implements RequestInterceptor {
    private static final Logger LOG = LoggerFactory.getLogger(FeignTxInterceptor.class);

    @Override
    public void apply(RequestTemplate template) {
        LOG.error(template.url());
        template.header(JtaParticipant.PRC_TRANSACTION_KEY, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}
